_base_ = ["../_base_/datasets/merge.py", "../_base_/default_runtime.py"]
# model settings
backbone_pretrained_path = ("https://download.pytorch.org/models"
                            "/shufflenetv2_x1-5666bf0f80.pth")
model = dict(
    type='FCOS',
    pretrained=backbone_pretrained_path,
    backbone=dict(type="ShuffleNetv2",
                  ratio=1.0,
                  out_stage_names=["stage2", "stage3", "conv5"]),
    neck=dict(
        type='FPN',
        in_channels=[116, 232, 1024],
        out_channels=256,
        num_outs=3),
    bbox_head=dict(type='FCOSHead',
                   num_classes=1,
                   in_channels=256,
                   regress_ranges=((-1, 64), (64, 128), (128, 256)),
                   stacked_convs=4,
                   feat_channels=256,
                   strides=[8, 16, 32],
                   loss_cls=dict(type='FocalLoss',
                                 use_sigmoid=True,
                                 gamma=2.0,
                                 alpha=0.25,
                                 loss_weight=1.0),
                   loss_bbox=dict(type='IoULoss', loss_weight=1.0),
                   loss_centerness=dict(type='CrossEntropyLoss',
                                        use_sigmoid=True,
                                        loss_weight=1.0)))
# training and testing settings
train_cfg = dict(assigner=dict(type='MaxIoUAssigner',
                               pos_iou_thr=0.5,
                               neg_iou_thr=0.4,
                               min_pos_iou=0,
                               ignore_iof_thr=-1),
                 allowed_border=-1,
                 pos_weight=-1,
                 debug=False)
test_cfg = dict(nms_pre=1000,
                min_bbox_size=0,
                score_thr=0.05,
                nms=dict(type='nms', iou_threshold=0.5),
                max_per_img=100)
# optimizer
# optimizer = dict(type="SGD", lr=0.001, momentum=0.9, weight_decay=0.0005)
optimizer = dict(type="Adam", lr=0.001, weight_decay=0.0005)
# optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
    policy="step",
    warmup="linear",
    warmup_iters=100,  # same as burn-in in darknet
    warmup_ratio=0.001,
    step=[40, 60])
# runtime settings
total_epochs = 70
